/*
 * Copyright (C) 2009 Jiannan Lu
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.restsql.atom;

import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author L
 */
public class Service {
    private static String ATOM_FORMAT = "http://www.w3.org/2005/Atom";
    private static String ATOM_PROTOCOL = "http://www.w3.org/2007/app";

    private List workspaces = new ArrayList();
     /**
     * Create new and empty Atom service
     */
    public Service() {
    }

     /**
     * Add Workspace to service.
     */
    public void addWorkspace(Workspace workspace) {
        workspaces.add(workspace);
    }

    /**
     * Set Workspaces of service.
     */
    public void setWorkspaces(List workspaces) {
        this.workspaces = workspaces;
    }

        /**
     * Get Workspaces available from service.
     */
    public List getWorkspaces() {
        return workspaces;
    }

        /**
     * Find workspace by title.
     * @param title Match this title
     * @return Matching Workspace or null if none found.
     */
    public Workspace findWorkspace(String title) {
        for (Iterator it = workspaces.iterator(); it.hasNext();) {
            Workspace ws = (Workspace) it.next();
            if (title.equals(ws.getTitle())) {
                return ws;
            }
        }
        return null;
    }
}
